package controller;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import wfm.entities.User;

@ManagedBean(name = "css")
@SessionScoped
public class CSSColorController {
	@ManagedProperty(value = "#{background}")
	private String background;

	@ManagedProperty(value="#{user}")
	User user;

	public CSSColorController() {
	}

	public String getBackground() {
		if (user != null) {
			String userGroup = user.getUserGroup();

			if(User.GROUP_DESKTOPWORKER.equals(userGroup))
				return "bgcolor-" + "dw";
			else if(User.GROUP_SUPERVISOR.equals(userGroup))
				return "bgcolor-" + "sv";
			else if(User.GROUP_SURVEYOR.equals(userGroup))
				return "bgcolor-" + "sr";
			else if(User.GROUP_WORKER.equals(userGroup))
				return "bgcolor-" + "wo";
			else 
				return "";
		}
		else {
			return "default";
		}
	}
	
	public String getUserGroupNameForCss(String userGroup){
		return userGroup.substring(5,userGroup.length()-1);
	}

	public void setBackground(String background) {
		this.background = background;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
